﻿using BSKTV.Server.View.Page;
using BSKTV.Server.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Wpf.Ui.Contracts;

namespace BSKTV.Server
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow
    {
        private ISnackbarService _snackbarService;
        private IDialogService _dialogService;
        private INavigationService _navigationService;

        public MainWindow()
        {
            Init();
        }

        private void Init()
        {
            Wpf.Ui.Appearance.Watcher.Watch(this);

            _navigationService = App.GetService<INavigationService>();
            _snackbarService = App.GetService<ISnackbarService>();
            _dialogService = App.GetService<IDialogService>();

            MainViewModel vm = App.GetService<MainViewModel>();

            DataContext = vm;

            InitializeComponent();

            _snackbarService.SetSnackbarControl(RootSnackbar);
            _navigationService.SetNavigationControl(Navigation);
            _dialogService.SetDialogControl(RootDialog);

            Navigation.SetServiceProvider(App.GetProvider());
            Navigation.Loaded += Navigation_Loaded;
            Navigation.SelectionChanged += Navigation_SelectionChanged;
        }

        private void Navigation_SelectionChanged(object sender, RoutedEventArgs e)
        {
            
        }

        private void Navigation_Loaded(object sender, RoutedEventArgs e)
        {
            Navigation.Navigate(typeof(HomePage));
        }
    }
}
